import 'package:get/get.dart';
import 'package:kkhousekeep/models/house_authentication_list_entity.dart';

import '../../config/enum.dart';


class HouseAuthenticationDetailController extends GetxController {
  late HouseAuthenticationListObjList _authenticationNotification;
  var status = "".obs;
  var time = "".obs;
  var applicationTime = "".obs;
  var name = "".obs;
  var phone = "".obs;
  var idCardType = "".obs;
  var idCarNumber = "".obs;
  var enterTime = "".obs;
  var image = "".obs;
  var isShowApplicationTimeInBottom = false.obs;
  @override
  void onInit() {
    _authenticationNotification = Get.arguments;
    var applicationTime = _authenticationNotification.createTime;
    var processingTime = _authenticationNotification.updateTime;
    CheckStatus? checkStatus =
        checkCheckStatus(_authenticationNotification.checkStatus);
    status.value = checkStatus?.description ?? "";
    if (checkStatus == CheckStatus.unchecked) {
      isShowApplicationTimeInBottom.value = false;
      time.value = "发起时间 $applicationTime";
    } else {
      time.value = "处理时间 $processingTime";
      this.applicationTime.value = "发起时间 $applicationTime";
      isShowApplicationTimeInBottom.value = true;
    }
    name.value = _authenticationNotification.name;
    phone.value = _authenticationNotification.phone;
    idCardType.value =
        checkIdCardType(_authenticationNotification.iDCardType)
                ?.description ??
            "";
    idCarNumber.value = _authenticationNotification.iDCard;
    enterTime.value = _authenticationNotification.enterTime;
    image.value = _authenticationNotification.image;
    super.onInit();
  }

  CheckStatus? checkCheckStatus(int status) {
    CheckStatus? checkStatus;
    CheckStatus.values.asMap().forEach((key, value) {
      if (value.value == status) {
        checkStatus = value;
      }
    });
    return checkStatus;
  }

  IdCardType? checkIdCardType(String type) {
    IdCardType? idCardType;
    IdCardType.values.asMap().forEach((key, value) {
      if (value.value == type) {
        idCardType = value;
      }
    });
    return idCardType;
  }
}
